﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Master/MasterBody.Master" AutoEventWireup="true" CodeBehind="Registration.aspx.cs" Inherits="Besture.UI.Land.Registration" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="Content" runat="server">
    <div class="main">
		<div class="w980">
            <div class="land-cen clearfix">
            	<div class="land-left">
                	<img src="/Upload/Images/Land/<%=_BannerLeft.ImageUrl%>"/>
                </div>
                <div class="land-right">
                	<div class="land-top clearfix">
                    	<span class="land-top1">注册</span>
                        <span class="land-top2">已有账号？<a href="Land.aspx">立即登录</a></span>
                    </div>
                    <div class="land-rtab land-rtaba">
                        	<table width="100%" class="safety-tab">
                              <tr>
                                <td class="safety-td">姓名：</td>
                                <td><input ID="txtNickName" runat="server" type="text" value="" class="required" placeholder="请输入您的真实姓名" name="one3"/></td>
                              </tr>
                              <tr class="errortr">
                                 <td class="safety-td">&nbsp;</td>
                                 <td>&nbsp;</td>
                              </tr>
                              <tr>
                                <td class="safety-td">手机号码：</td>
                                <td><input id="txtTelphone" runat="server" type="text" value="" placeholder="请输入您的手机号" class="required mobile" name="mobile" maxlength="11" /></td>
                              </tr>
                              <tr class="errortr">
                                 <td class="safety-td">&nbsp;</td>
                                 <td><span id="EmailError" runat="server"></span></td>
                              </tr> 
                              <tr>
                                <td class="safety-td">验证码：</td>
                                <td class="safety-tdd"><input id="registerCode" runat="server" type="text" value="" class="required" placeholder="验证码" maxlength="6" /> <a id="checkcode" href="javascript:void(0);" onclick="return CheckCode();" >获取短信验证码</a></td>
                              </tr>
                              <tr class="errortr">
                                 <td class="safety-td">&nbsp;</td>
                                 <td><span id="CardError" style="color: red;display: none">验证码不正确</span></td>
                              </tr>
                              <tr>
                                <td class="safety-td">密码：</td>
                                <td><input id="registerPwd" runat="server" type="password" value="" class="required" name="one4" placeholder="密码"/></td>
                              </tr>
                              <tr class="errortr">
                                 <td class="safety-td">&nbsp;</td>
                                 <td>&nbsp;</td>
                              </tr>
                              <tr>
                                <td class="safety-td">确认密码：</td>
                                <td><input id="registerPwdSure" runat="server" type="password" value="" class="required" name="one" placeholder="确认密码"/></td>
                              </tr>
                              <tr class="errortr">
                                 <td class="safety-td">&nbsp;</td>
                                 <td>&nbsp;</td>
                              </tr>
                              <tr>
                                <td class="safety-td">&nbsp;</td>
                                <td class="safety-tda"><asp:Button ID="btnRegistration" runat="server" Text="注册"  OnClick="btnRegistration_Click" /></td>
                              </tr>
                            </table>
                            <p class="land-p">如需帮助，请拨打客服热线  <span> 400-820-0025 </span> </p>
                        </div>
                </div>
            </div>
        </div>
	</div><!-- //main -->
    <input type="hidden" id="EmailStatus" runat="server" />
    <input type="hidden" id="hidIsOnLine" value="<%=_IsOnLine %>" />
    <script type="text/javascript">
        $(function () {
            $("#aspnetForm").validate({
                errorPlacement: function (error, element) {
                    error.appendTo(element.parent().parent().next(".errortr").children("td:eq(1)"));
                }
            });
        });
</script>
<script type="text/javascript">
    //获取手机验证码按钮验证
    var t;
    function CheckCode() {

        var vtxt = $("#checkcode").html();
        if (vtxt != "重新发送"&&vtxt != "获取短信验证码") {
            return false;
        }
        if ($("#<%=txtTelphone.ClientID %>").val() != "") {
            var Telphone = $("#<%=txtTelphone.ClientID %>").val();
            var reg = /^1[3|4|5|8][0-9]\d{4,8}$/;
            var emailExp = new RegExp(reg);
            if (emailExp.test(Telphone)) {
                //异步验证手机
                $("#checkcode").html("请稍后");
                $.post(
                        "/ajax/AjaxPage.aspx?Mobile=" + Telphone + "",
                        function (data) {
                            if (data == "1") {
                                $("#<%=EmailError.ClientID %>").html("手机号已被注册，请更换手机号");
                                $("#<%=EmailError.ClientID %>").removeClass();
                                $("#<%=EmailError.ClientID %>").addClass("Red");
                                $("#<%=EmailStatus.ClientID %>").val(1);
                                //发送手机验证码
                                $("#checkcode").html("重新发送");
                            } else {
                                $("#<%=EmailError.ClientID %>").html("恭喜你，手机号可用");
                                $("#<%=EmailError.ClientID %>").removeClass();
                                $("#<%=EmailError.ClientID %>").addClass("Green");
                                $("#<%=EmailStatus.ClientID %>").val(0);
                                $.post("/ajax/AjaxPage.aspx?SendSMS=" + Telphone + "",
                                    function (data1) {
                                        if ($("#hidIsOnLine").val() == "0") {
                                            //alert(data1);
                                            t = setInterval(timer, 1000); //发送成功之后数秒
                                        } else {
                                            if (data1 == "1") {
                                                alert("验证码已发送，请确认查收");
                                                t = setInterval(timer, 1000); //发送成功之后数秒
                                            } 
                                        }
                                    }
                                );
                            }
                        }
                    );
            } else {
                $("#<%=EmailError.ClientID %>").html("输入手机号不正确，请重新输入");
                $("#<%=EmailError.ClientID %>").removeClass();
                $("#<%=EmailError.ClientID %>").addClass("Red");
                $("#txtTelphone").focus();
            };

        } else {
            $("#<%=EmailError.ClientID %>").html("手机号不能为空，请输入手机号");
            $("#<%=EmailError.ClientID %>").removeClass();
            $("#<%=EmailError.ClientID %>").addClass("Red");
            $("#txtTelphone").focus();
        }
    }

    //错误消失
    $("#<%=txtTelphone.ClientID %>").bind({
        focus: function () {
            $("#<%=EmailError.ClientID %>").html(" ");
            $("#<%=EmailError.ClientID %>").removeClass();
            $("#<%=EmailError.ClientID %>").addClass("Red");
        }
    });
    //手机注册时间计时
    var sumSecond = 299;
    var scrollTimer = 4;
    function timer() {
        if (sumSecond <= 0) {
            $("#checkcode").html("重新发送");
            clearInterval(t);
            sumSecond = 299;
            scrollTimer = 4;
            return 0;
        }
        if (scrollTimer > 0) {
            $("#checkcode").html(scrollTimer + 1 + "分钟后重发");
        }
        else {
            $("#checkcode").html(sumSecond + "秒后重发");
        }
        sumSecond -= 1;
        if (sumSecond / 60 == scrollTimer) {
            scrollTimer -= 1;
        }
    }
</script>
</asp:Content>
